<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">{{Lang.lang('競猜')}}</view>
			<view class="message iconfont icon-tongzhi" data-url="/pages/index/tidings" @click="gotopage">
				<view class="round" v-if="is_message_read==1"></view>
			</view>
			<picker @change="choiceLang" :value="langIndex" :range="Lang.lang('langData')" :range-key="'name'">
				<view class="language" v-if="lang == 'en'">EN</view>
				<view class="language" v-else>CN</view>
			</picker>
		</view>
		<view class="clear_box"></view>

		<view class="page_content">
			<view class="gameplay_list" data-url="/pages/guess/gameplay01" @click="gotopage">
				<image v-if="lang=='tc'" src="../../static/game/game_w_1_tc.png" mode="widthFix"></image>
				<image v-if="lang=='en'" src="../../static/game/game_w_1_en.png" mode="widthFix"></image>
			</view>
			<view class="gameplay_list" data-url="/pages/guess/gameplay02" @click="gotopage">
				<image v-if="lang=='tc'" src="../../static/game/game_w_2_tc.png" mode="widthFix"></image>
				<image v-if="lang=='en'" src="../../static/game/game_w_2_en.png" mode="widthFix"></image>
			</view>
			<view class="gameplay_list" data-url="/pages/guess/gameplay03" @click="gotopage">
				<image v-if="lang=='tc'" src="../../static/game/game_w_3_tc.png" mode="widthFix"></image>
				<image v-if="lang=='en'" src="../../static/game/game_w_3_en.png" mode="widthFix"></image>
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				lang: 'en',
				langIndex: '',
				link: '',
				pupu: false,
				scrrol: false,
				info: '',
				is_message_read: 0
			}
		},
		onLoad() {

		},
		onShow() {
			this.setMenuLang();
			this.lang = uni.getStorageSync('_language');
			this.loadData();
		},
		methods: {
			setMenuLang() {
				let that = this;
				uni.setTabBarItem(this.Lang.lang('indexMenu')[0]);
				uni.setTabBarItem(this.Lang.lang('indexMenu')[1]);
				uni.setTabBarItem(this.Lang.lang('indexMenu')[2]);
				uni.setTabBarItem(this.Lang.lang('indexMenu')[3]);
				uni.setTabBarItem(this.Lang.lang('indexMenu')[4]);
			},
			choiceLang: function(e) {
				let that = this;
				that.langIndex = e.target.value
				let lang = that.Lang.lang('langData')[that.langIndex].type;
				that.lang = lang;
				uni.setStorageSync('_language', lang);
				// that.setMenuLang();
				location.reload()
			},
			loadData() {
				let that = this;
				that.Net._post('api/game/gameIndex', {}, res => {
					if (res.code == 200) {
						that.is_message_read = res.data.is_message_read

					}
				});
			},
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},
		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		},
	}
</script>

<style>
	.scrrolHeader {
		width: 100%;
		background-color: #1A1A1A !important;

	}

	.page_content {
		width: 92%;
		margin: 0 auto;
	}

	.gameplay_list {
		width: 100%;
		margin-top: 4%;
	}

	.gameplay_list image {
		width: 100%;
	}
</style>
